<?php
require_once ("../../../init.php");
include("pinyin.php");

//产品缩略图
/*
for($i=619;$i<711;$i++){
    $s=Seriesimg::get_by_id($i);
    $s->img="product/".Pinyin::translate($s->img,'utf8').".jpg";
    $s->image_large="product/large/".Pinyin::translate($s->image_large,'utf8').".jpg";
    $s->update();
}
*/
//商品信息图片是否存在
/*
echo "<table style='width:500px;float:left;'>\n";
echo "<tr><td colspan='2' style='text-align:center;color:#f00;'>有商品信息没有图片（名称、图片）</td></tr>\n";
for($i=611;$i<703;$i++){
    $p=Productimport::get_by_id($i);
    $filename=Gc::$nav_root_path."Pic\\300x300".DIRECTORY_SEPARATOR.iconv("utf-8","gb2312",$p->image_cn).".jpg";
    if(file_exists($filename)){
        $p->image="product/".Pinyin::translate($p->image_cn,"utf8").".jpg";
        $p->image_large="product/large/".Pinyin::translate($p->image_large_cn,"utf8").".jpg";
        $p->update();
    }else{
        echo "<tr><td>".$p->name."</td><td>".$p->image_cn."</td></tr>\n"; 
    }
}
echo "</table>\n";
*/
//产品图片
/*
for($i=611;$i<703;$i++){
    $s=Productimport::get_by_id($i);
    $s->image="product/".Pinyin::translate($s->image,'utf8').".jpg";
    $s->image_large="product/large/".Pinyin::translate($s->image_large,'utf8').".jpg";
    $s->update();
}
*/

//产品导入
/*
for($i=611;$i<703;$i++){
    $pimport=Productimport::get_by_id($i);
    $p=new Product();
    $p->product_id=$pimport->productimport_id;
    $p->product_code=$pimport->product_code;
    $p->name=$pimport->name;
    $p->image=$pimport->image;
    $p->image_large=$pimport->image_large;
    $p->market_price=$pimport->market_price;
    $p->price=$pimport->price;
    $p->num=$pimport->num;
    $p->intro=$pimport->intro;
    //品牌
    $brand=Brand::get_one("brand_name='".$pimport->brand."'");
    $p->brand_id=$brand->brand_id;
    //类型
    $p->ptype1_id=221;
    $ptype=Ptype::get_one("name='".$pimport->ptype."'");
    $p->ptype_id=$ptype->ptype_id;
    $p->ptype2_id=$ptype->parent_id;
    $p->save();
}
*/

//票券导入处理
/*
$index=0;
for($i=1;$i<624;$i++){
    $cimport=Couponimport::get_by_id($i);
    $cp0=Couponproduct::get_one("couponproduct_id<747 and product_code='".$cimport->code."'");
    if(!empty($cp0->couponproduct_name)){
        $cp=new Couponproduct();
        $cp->product_code=$cimport->card;
        $cp->couponproduct_name=$cp0->couponproduct_name;
        $cp->save();
        echo ++$index."<br/>";
    }
    if(!empty($cimport->codelist)){
        $ar=explode(",",$cimport->codelist);
        for($j=0;$j<count($ar);$j++){
            $cp0=Couponproduct::get_one("couponproduct_id<747 and product_code='".$ar[$j]."'");
            if(!empty($cp0->couponproduct_name)){
                $cp=new Couponproduct();
                $cp->product_code=$cimport->card;
                $cp->couponproduct_name=$cp0->couponproduct_name;
                $cp->save();
                echo ++$index."<br/>";
            }
        }
    }
}
*/

//添加商品显示
/*
$ar=array(614,616,617,618,619,620,623,625,627,628,631,632,636,640,641,642,645,650,651,655,656);
for($i=0;$i<count($ar);$i++){
    $p=Product::get_by_id($ar[$i]);
    $cp=new Cptypeshow();
    $cp->product_id=$p->product_id;
    $cp->name=$p->name;
    if($i<8){
        $cp->showtype=1;
    }else{
        $cp->showtype=2;
    }
    $cp->unit=$p->unit;
    $cp->market_price=$p->market_price;
    $cp->price=$p->price;
    $cp->isShow=1;
    $cp->sort_order=50;
    $cp->image=$p->image;
    $cp->save();
}
*/

?>